import request from '../../utils/Request'
import PageUtils from '../../utils/PageUtils'

export const saveServer = data => {
  return request({
    method: 'post',
    url: '/api/monitor/server/save',
    data: data
  })
}

export const createServer = (data, idempotentCode) => {
  return request({
    method: 'post',
    url: '/api/monitor/server/create',
    data: data,
    headers: {
      common: {
        idempotent: idempotentCode
      }
    }
  })
}

export const updateServer = data => {
  return request({
    method: 'post',
    url: '/api/monitor/server/update',
    data: data
  })
}

export const updateServerStatus = (serverId, status) => {
  return request({
    method: 'get',
    url: '/api/monitor/server/' + serverId + '/status/' + status,
    params: {}
  })
}

export const deleteServer = bId => {
  return request({
    method: 'get',
    url: '/api/monitor/server/delete/' + bId,
    params: {}
  })
}

export const listServer = (data, current, size) => {
  let pageUrl = PageUtils.page(current, size)
  return request({
    method: 'get',
    url: '/api/monitor/server/list?' + pageUrl,
    params: data
  })
}

export const selectServer = bId => {
  return request({
    method: 'get',
    url: '/api/monitor/server/select/' + bId,
    params: {}
  })
}